package co.edu.usbcali.csru.modelo.dto;

import co.edu.usbcali.csru.modelo.TipoConcepto;
import co.edu.usbcali.csru.presentation.backingBeans.TipoConceptoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class TipoConceptoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String tcoNombre;
    private String tcoCodigo;
    private boolean rowSelected = false;
    private TipoConceptoView tipoConceptoView;
    private TipoConcepto tipoConcepto;

    public TipoConcepto getTipoConcepto() {
        return tipoConcepto;
    }

    public String listener_update(ActionEvent e) {
        try {
            tipoConceptoView.action_modifyWitDTO(((tcoCodigo == null) ||
                tcoCodigo.equals("")) ? null : new String(tcoCodigo),
                ((tcoNombre == null) || tcoNombre.equals("")) ? null
                                                              : new String(
                    tcoNombre));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        tcoCodigo = tipoConcepto.getTcoCodigo().toString();
        tcoNombre = (tipoConcepto.getTcoNombre() != null)
            ? tipoConcepto.getTcoNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        tcoCodigo = tipoConcepto.getTcoCodigo().toString();
        tcoNombre = (tipoConcepto.getTcoNombre() != null)
            ? tipoConcepto.getTcoNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setTipoConcepto(TipoConcepto tipoConcepto) {
        this.tipoConcepto = tipoConcepto;
    }

    public TipoConceptoView getTipoConceptoView() {
        return tipoConceptoView;
    }

    public void setTipoConceptoView(TipoConceptoView tipoConceptoView) {
        this.tipoConceptoView = tipoConceptoView;
    }

    public String getTcoNombre() {
        return tcoNombre;
    }

    public void setTcoNombre(String tcoNombre) {
        this.tcoNombre = tcoNombre;
    }

    public String getTcoCodigo() {
        return tcoCodigo;
    }

    public void setTcoCodigo(String tcoCodigo) {
        this.tcoCodigo = tcoCodigo;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
